package wc.Dao;

import com.github.houbb.data.factory.core.util.DataUtil;
import com.github.houbb.heaven.util.util.DateUtil;
import wc.Dao.AdminDao;
import wc.Dao.DaoImpl.AdminDaoImpl;
import wc.domain.Admin;
import org.junit.jupiter.api.Test;
import wc.domain.History;
import wc.domain.User;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName:AdminDaoImplTest
 * @Author: 鹿建文
 * @Date: 2022/4/6  - 10:37
 * @Describe:
 */
class AdminDaoImplTest {
   AdminDao adminDao =new AdminDaoImpl();

    @Test
    void selectByAccount() throws SQLException {
        Admin admin = adminDao.selectByAccount("zhangsan");
        System.out.println(admin);

    }
    @Test
    void selectById() throws SQLException {
        Admin admin = adminDao.selectById(1001);
        System.out.println(admin);

    }
    @Test
    void updatePassword() throws SQLException {
//        boolean b = adminDao.updatePassword(1001, "1234");
//        System.out.println(b);
    }

    @Test
    void  updateSalt() throws SQLException {
        boolean d = adminDao.updateSalt(1002, "fSnOwFgdExsTgsOE");
        System.out.println(d);
    }

    @Test
    void updateAllSaltAndPassword() throws SQLException {
        int i = adminDao.updateAllSaltAndPassword();
        System.out.println(i);
    }
    @Test
    void createUser() throws SQLException {
        User user = DataUtil.build(User.class);
        boolean res = adminDao.createUser(user);
        System.out.println(res);
    }
    @Test
    void selectAllUsersDetailed() throws SQLException {
        List<User> users = adminDao.selectAllUsersDetailed();
        users.forEach(System.out::println);
    }
    @Test
    void selectAllUsersList() throws SQLException {
        HashMap<Integer, List> res = adminDao.selectAllUsersList();
        res.forEach((k,v)->System.out.println("id="+k+":" +v));
    }
    @Test
    void selectUserCredits() throws SQLException {

        HashMap<Integer,List> res = adminDao.selectUserCredits("aa");
        res.forEach((k,v)->System.out.println("id="+k+":" +v));
    }
    @Test
    void selectUserCreditsHistorye() throws SQLException {
        ArrayList<History> rs = adminDao.selectUserCreditsHistorye(1);
        rs.forEach(System.out::println);
    }
}